package 数据结构OJ;

/**
 * @author shy_black
 * @date 2019/3/18 15:43
 * @Description:
 */
public class 镜象二叉树 {
    public class TreeNode {
        int val = 0;
        TreeNode left = null;
        TreeNode right = null;

        public TreeNode(int val) {
            this.val = val;

        }

    }

    public class Solution {
        public void Mirror(TreeNode root) {
            if (root == null) {
                return;
            }
            //交换左右子树
            TreeNode temp = root.left;
            root.left = root.right;
            root.right = temp;
            //递归交换左右子树
            Mirror(root.left);
            Mirror(root.right);
        }
    }
}
